<if condition="IS_AJAX">
      <volist name="list" id="vo">
          <div class="panel">
            <div class="panel-heading">
              <div class="panel-title"> 
              	<a class="accordion-toggle collapsed" data-parent="#accordion" data-toggle="collapse" href="#collapse{$vo.id}">
                	<div class="pull-right text-<?php echo $vo['changenum']>0?'success':'danger' ?>">{$vo.changenum}</div>{$vo.name} 
                </a> 
              </div>
            </div>
            <div class="panel-collapse collapse" id="collapse{$vo.id}" style="height: 0;">
              <div class="panel-body ui-table-split" style="margin-bottom:10px;" >
                <div class="pull-right">
                  <button id="modify" class="btn-xs btn-info-outline modify" key="{$key}">修改</button>
                </div>
                <div><span class="glyphicon glyphicon-flag text-primary" aria-hidden="true"><strong>部 门：</strong></span><font class="title{$key}">{$vo.group_title}</font></div>
                <div><span class="glyphicon glyphicon-time text-primary" aria-hidden="true"><strong>时 间：</strong></span><font class="date{$key}">{:date('Y-m-d',$vo['time'])}</font></div>
                <div><span class="glyphicon glyphicon-user text-primary" aria-hidden="true"><strong>操作者：</strong></span><font class="giver{$key}">{$vo.givername}</font></div>
                <div><span class="glyphicon glyphicon-user text-primary" aria-hidden="true"><strong>奖惩者：</strong></span><font class="rewarder{$key}">{$vo.rewardername}</font></div>
                <div><span class="glyphicon glyphicon-list text-primary" aria-hidden="true"><strong>类 型：</strong></span><font class="type{$key}">{$vo.type_name}</font></div>
                <div><span class="glyphicon glyphicon-info-sign text-primary" aria-hidden="true"><strong>详 情：</strong></span><font class="remark{$key}">{$vo.remark}</font></div>
              </div>
            </div>
          </div>
      </volist>
<else/>
    <include file="Public:header" /> <include file="Public:navgation" />
    <div class="container-fluid main-content">
      <style>
    .edit-input{border:0 solid;width:auto;}
    </style>
      <script>
    /*function editRow ( oTable, nRow )
    {
      var aData = oTable.fnGetData(nRow);
      var jqTds = $('>td', nRow);
      jqTds[0].innerHTML = aData[0];
      jqTds[1].innerHTML = aData[1];
      jqTds[2].innerHTML = '<input name="integralnum" class="form-control" type="number" value="'+aData[2]+'">';
      jqTds[3].innerHTML = $(".integralruletype").parent().html()+$(".integralrule").parent().html();
      jqTds[4].innerHTML = '<textarea name="remark" class="form-control" type="text" value="">'+aData[4]+'</textarea>';
      jqTds[5].innerHTML = aData[5];
      jqTds[6].innerHTML = '<a class="edit-row" href="'+'"><i class="icon-ok"></i></a>';
    }
    function saveRow ( oTable, nRow)
    {
      var jqInputs = $('>td .form-control', nRow);
      oTable.fnUpdate( jqInputs[0].value, nRow, 2, false );
      oTable.fnUpdate($(jqInputs[2]).find("[value='"+Number(jqInputs[2].value)+"']").text(), nRow, 3, false );
      oTable.fnUpdate( jqInputs[3].value, nRow, 4, false );
      
      oTable.fnUpdate( '<a class="edit-row" href="javascript:void(0)"><i class="icon-pencil"></i></a>', nRow, 6, false );
      oTable.fnDraw();
    }*/
    
    </script>
      <div class="page-title chart-container"> </div>
      <div class="row">
        <div class="col-md-12">
          <div class="widget-container">
            <div class="heading" style=" margin-bottom:10px; line-height:35px;"> <i class="icon-bar-chart"></i>积分事件
              <?php if(!isMobile()){ ?>
              	<a class="btn btn-default btn pull-right" data-toggle="modal" href="#myModal2" >筛选</a>
                	<a class="btn btn-primary btn pull-right f-fillwidth" data-toggle="modal" href="#myModal">添加</a> 
              <?php } ?>
            </div>
            <div class="widget-content padded modal-open" style="background:#fff; padding:15px;">
              <div>总分：<span class="text-primary">{$totalnum}</span></div>
              <if condition="!isMobile()">
                <table id="datatable-editable" class="table table-striped table-bordered dataTable">
                  <thead>
                     <tr>
                      <th>序号</th>
                      <th>职员</th>
                      <th class="hidden-xs">积分类型</th>
                      <th>积分</th>
                      <th class="hidden-sm hidden-xs">时间</th>
                      <th>规则</th><!--
                      <th class="hidden-sm hidden-xs">奖/惩人</th>
                      <th class="hidden-sm hidden-xs">操作人</th>
                      <th class="hidden-xs">部门</th>-->
                      <th>原因</th>
                      <th></th>
                    </tr>
                  </thead>
                  <volist name="list" id="voi" empty="$empty">
                     <tr class="data_list {$key}">
                      <td>{$i}</td>
                      <td>{$voi.membername}</td>
                      <td class="hidden-xs"><?php echo $integraltypearr[$voi['integral_type']] ?>  {$voi.integralname}</td>
                      <td>{$voi.changenum}</td>
                      <td class="hidden-sm hidden-xs">{:date('Y-m-d',$voi['time'])}</td>
                      <td>{$voi.rule_id}</td>
                      <td>{$voi.remark}</td>
                      <td class="text-center actions">
                      	<a class="fancybox table-actions"  href="#fancybox" href="#" ><i class="icon-eye-open"></i></a>
                        <?php $month=strtotime('-1 month');  ?>
                        <egt name="voi['time']" value="$month">
                          	<a class="table-actions update f-fillwidth" data-rewarderid="{$voi.rewarder_id}" data-groupid="{$voi.group_id}" data-id="{$voi.rule_id}" data-ruletype="{$voi.type_id}" href="{:U('update',array('id'=>$voi['id']))}"><i class="icon-pencil"></i></a> 
                          	<a class="delete-row table-actions" href="{:U('delete',array('id'=>$voi['id']))}" row="{$key}"><i class="icon-trash text-danger"></i></a> 
                        </egt>
                      </td>
                    </tr>
                  </volist>
                </table>
                <div class="text-right">{$pages}</div>
              <else/>
                    <div class="panel-group tbody" id="accordion"></div>
					<script>
                        $(".tbody").more({'address':location.href});
                    </script>
              </if>
              <!--modal3 修改 start-->
              <div class="modal fade" id="myModal3" style="display: none;" aria-hidden="true">
                <div class="modal-dialog">
                  <div class="modal-content">
                    <form method="post" name="form" id="validate-form" class="form-horizontal" novalidate action="__URL__/update">
                      <div class="modal-header">
                        <button aria-hidden="true" class="close" data-dismiss="modal" type="button">×</button>
                        <h4 class="modal-title">修改积分事件</h4>
                      </div>
                      <div class="modal-body">
                        <fieldset>
                          <div class="form-group">
                            <label class="control-label col-sm-2">积分规则</label>
                            <div class="col-sm-5 typeevent">
                              <select class="form-control integralruletype">
                                <foreach name="ruletypelist" item="vo">
                                  <option value="{$vo.id}">{$vo.name}</option>
                                </foreach>
                              </select>
                            </div>
                            <div class="col-sm-5">
                              <select class="form-control integralrule .f-ruleinfo" name="rule_id">
                              </select>
                            </div>
                          </div>
                          <!--<div class="form-group">
                            <label class="control-label col-sm-2">积分类型</label>
                            <div  class="col-sm-10">
                                <select class="form-control" name="typeid">
                                    <foreach name="integraltypelist" item="vo">
                                        <option value="{$vo.typename}">{$vo.remark}</option>
                                    </foreach>
                                </select>
                            </div>
                        </div>-->
                          <div class="form-group">
                            <label class="control-label col-sm-2">奖/惩人</label>
                            <div  class="col-sm-5">
                              <select class="form-control groupid" >
                                <foreach name="grouplist" item="vo">
                                  <option value="{$vo.id}">{$vo.name}</option>
                                </foreach>
                              </select>
                            </div>
                            <div class="col-sm-5">
                              <select class="form-control memberid" name="rewarder_id">
                              </select>
                            </div>
                          </div>
                          <div class="form-group">
                            <label class="control-label col-sm-2">奖/惩时间</label>
                            <div  class="col-sm-10" style="z-index:1050;">
                              <div class="input-group date datepicker" data-date-autoclose="true" data-date-format="dd-mm-yyyy">
                                <input class="form-control" type="text" name="date">
                                <span class="input-group-addon"><i class="icon-calendar"></i></span> </div>
                            </div>
                          </div>
                          <div class="form-group">
                            <label class="control-label col-sm-2">积分数量</label>
                            <div class="col-sm-10">
                              <input class="form-control" name="changenum" type="number">
                            </div>
                          </div>
                          <div class="form-group"> 
                            <!--<label class="control-label col-sm-2">原因</label>-->
                            <div class="col-sm-12">
                            </div>
                          </div>
                        </fieldset>
                      </div>
                      <div class="modal-footer">
                        <button class="btn btn-primary" type="submit">修改积分</button>
                        <button class="btn btn-default-outline" data-dismiss="modal" type="button">关闭</button>
                      </div>
                    </form>
                  </div>
                </div>
              </div>
              <!--modal 添加 start-->
              <div class="modal fade" id="myModal" style="display: none;" aria-hidden="true">
                <div class="modal-dialog">
                  <div class="modal-content">
                    <form method="post" name="form" id="validate-form2" class="form-horizontal" novalidate action="__URL__/insert">
                      <div class="modal-header">
                        <button aria-hidden="true" class="close" data-dismiss="modal" type="button">×</button>
                        <h4 class="modal-title">添加积分事件</h4>
                      </div>
                      <div class="modal-body">
                        <fieldset>
                          <div class="form-group"> 
                            <!--<label class="control-label col-sm-2">积分规则</label>-->
                            <div class="col-sm-6 typeevent">
                              <select class="form-control integralruletype">
                                <option >请选择积分规则</option>
                                <volist name="ruletypelist" id="vo">
                                    <option value="{$vo.id}">{:getdeepstr($vo['cl'])}{$vo.name}</option>
                                </volist>
                              </select>
                            </div>
                            <div class="col-sm-6">
                              <select class="form-control integralrule f-ruleinfo" name="ruleid">
                                <option >请选择积分事件</option>
                              </select>
                            </div>
                          </div>
                          <div class="form-group"> 
                            <!--label class="control-label col-sm-2">积分类型</label>-->
                            <div  class="col-sm-12">
                              <select class="form-control" name="typeid">
                                <foreach name="integraltypelist" item="vo">
                                  <option value="{$vo.typename}">{$vo.remark}</option>
                                </foreach>
                              </select>
                            </div>
                          </div>
                          <div class="form-group"> 
                            <!--<label class="control-label col-sm-2">选择员工</label>-->
                            <div class="col-sm-12">
                              <div class="input-group">
                                <input readonly class="form-control f-fillname" type="text" placeholder="请选择被奖人">
                                <input name="memberid" class="form-control" type="hidden">
                                <span class="input-group-btn">
                                <button class="btn btn-default fancybox" href="#fancybox1" type="button">选择</button>
                                </span> 
                              </div>
                            </div>
                          </div>
                          <div class="form-group"> 
                            <!--<label class="control-label col-sm-2">奖/惩人</label>-->
                            <div  class="col-sm-6 ">
                              <select class="form-control groupid" >
                                <option value="">请选择奖/惩人部门</option>
                                <foreach name="grouplist" item="vo">
                                  <option value="{$vo.id}">{$vo.name}</option>
                                </foreach>
                              </select>
                            </div>
                            <div class="col-sm-6 ">
                              <select class="form-control memberid" name="rewarder_id">
                                <option value="">请选择奖/惩人职员</option>
                              </select>
                            </div>
                          </div>
                          <div class="form-group"> 
                            <!--<label class="control-label col-sm-2">奖/惩时间</label>-->
                            <div  class="col-sm-6 " style="z-index:1050;">
                              <div class="input-group date datepicker" data-date-autoclose="true" data-date-format="dd-mm-yyyy">
                                <input class="form-control" type="text" name="date" value="请选择奖/惩时间">
                                <span class="input-group-addon"><i class="icon-calendar"></i></span> 
                              </div>
                            </div>
                            <div class="col-sm-6 ">
                              <input class="form-control" name="changenum" placeholder="输入奖励分数" type="number" >
                            </div>
                          </div>
                          <div class="form-group"> 
                            <!--<label class="control-label col-sm-2">原因</label>-->
                            <div class="col-sm-12">
                              <textarea name="remark" class="form-control" placeholder="请输入备注."></textarea>
                            </div>
                          </div>
                        </fieldset>
                      </div>
                      <div class="modal-footer">
                        <button class="btn btn-primary" type="submit">添加积分</button>
                        <button class="btn btn-default-outline" data-dismiss="modal" type="button">关闭</button>
                      </div>
                    </form>
                  </div>
                </div>
              </div>
              <!-- modal end and modal2 start-->
              <div class="modal fade" id="myModal2" style="display: none;" aria-hidden="true">
                <div class="modal-dialog">
                  <div class="modal-content">
                    <form method="get" name="form" class="form-horizontal" novalidate action="__URL__/index">
                      <div class="modal-header">
                        <button aria-hidden="true" class="close" data-dismiss="modal" type="button">×</button>
                        <h4 class="modal-title">规则筛选</h4>
                      </div>
                      <div class="modal-body">
                        <fieldset>
                          <div class="form-group">
                            <label class="control-label col-sm-2">职员部门</label>
                            <div  class="col-sm-5">
                              <select class="form-control groupid" name="groupid">
                                <option value="">选择部门</option>
                                <foreach name="grouplist" item="vo">
                                  <option value="{$vo.id}">{$vo.name}</option>
                                </foreach>
                              </select>
                            </div>
                            <div class="col-sm-5">
                              <select class="form-control memberid" name="member_id">
                                <option value="">选择职员</option>
                              </select>
                            </div>
                          </div>
                          <div class="form-group">
                            <label class="control-label col-sm-2">积分规则</label>
                            <div class="col-sm-5 typeevent">
                              <select class="form-control integralruletype" name="ruletypeid">
                                <option value="">选择规则分类</option>
                                <foreach name="ruletypelist" item="vo">
                                  <option value="{$vo.id}">{$vo.name}</option>
                                </foreach>
                              </select>
                            </div>
                            <div class="col-sm-5">
                              <select class="form-control integralrule" name="rule_id">
                                <option value="">选择规则</option>
                              </select>
                            </div>
                          </div>
                          <div class="form-group">
                            <label class="control-label col-sm-2">积分类型</label>
                            <div  class="col-sm-5">
                              <select class="form-control" name="type_id">
                                <option value="">选择类型</option>
                                <foreach name="integraltypelist" item="vo">
                                  <option value="{$vo.id}">{$vo.remark}</option>
                                </foreach>
                              </select>
                            </div>
                          </div>
                          <div class="form-group">
                            <label class="control-label col-sm-2">奖/惩积分</label>
                            <div  class="col-sm-5">
                              <select class="form-control" name="rewardstype">
                                <option value="">选择分种</option>
                                <option value="1">加分</option>
                                <option value="2">减分</option>
                              </select>
                            </div>
                          </div>
                          <div class="form-group">
                            <label class="control-label col-sm-2">日期范围</label>
                            <div class="col-sm-5" style="z-index:1050;">
                              <input name="starttime" class="form-control" data-date-autoclose="true" data-date-format="dd-mm-yyyy" id="dpd1" placeholder="开始日期" type="text">
                            </div>
                            <div class="col-sm-5" style="z-index:1050;">
                              <input name="endtime" class="form-control" data-date-autoclose="true" data-date-format="dd-mm-yyyy" id="dpd2" placeholder="结束日期" type="text">
                            </div>
                          </div>
                        </fieldset>
                      </div>
                      <div class="modal-footer">
                        <button class="btn btn-primary" type="submit">筛选</button>
                        <button class="btn btn-default-outline" data-dismiss="modal" type="button">关闭</button>
                      </div>
                    </form>
                  </div>
                </div>
              </div>
              <!-- modal end and modal3 start-->
              <div class="modal fade" id="myModal4" style="display: none;" aria-hidden="true">
                <div class="modal-dialog">
                  <div class="modal-content">
                    <form method="get" name="form" class="form-horizontal" novalidate action="__URL__/changetype">
                      <div class="modal-header">
                        <button aria-hidden="true" class="close" data-dismiss="modal" type="button">×</button>
                        <h4 class="modal-title">积分类型转换</h4>
                      </div>
                      <div class="modal-body">
                        <fieldset>
                          <div class="form-group">
                            <input type="hidden" name="id"/>
                            <label class="control-label col-sm-2">积分类型</label>
                            <div  class="col-sm-10">
                              <select class="form-control" name="type_id">
                                <option value="">选择类型</option>
                                <foreach name="integraltypelist" item="vo">
                                  <option value="{$vo.id}">{$vo.remark}</option>
                                </foreach>
                              </select>
                            </div>
                          </div>
                        </fieldset>
                      </div>
                      <div class="modal-footer">
                        <button class="btn btn-primary" type="submit">筛选</button>
                        <button class="btn btn-default-outline" data-dismiss="modal" type="button">关闭</button>
                      </div>
                    </form>
                  </div>
                </div>
              </div>
              <!-- modal end and fancybox1 start-->
              <div id="fancybox" style="display: none;">
                <h4 class="text-muted">查看</h4>
                <ul class="no-style">
                </ul>
              </div>
              <!-- fancybox1 end and fancybox1 start-->
              <div id="fancybox1" style="display: none;">
                <ul class="nav nav-tabs" role="tablist">
                  <foreach name="memberlist" item="vo">
                    <li role="presentation"><a href="#{$key}" aria-controls="{$key}" role="tab" data-toggle="tab">{$key}</a></li>
                  </foreach>
                </ul>
                
                <!-- Tab panes -->
                <div class="tab-content" style="min-height:160px">
                  <foreach name="memberlist" item="vo">
                    <div role="tabpanel" class="tab-pane" id="{$key}">
                      <foreach name="vo" item="ko">
                        <label class="checkbox-inline">
                          <input name="staff" type="checkbox" value="{$ko.id}">
                          <span>{$ko.name}</span></label>
                      </foreach>
                    </div>
                  </foreach>
                </div>
                <div class="col-xs-12">
                  <label class="checkbox-inline checkall">
                    <input type="checkbox">
                    <span>全选</span></label>
                  <button class="btn btn-primary btn-md pull-right f-getstaff">确定</button>
                </div>
              </div>
              <!-- fancybox1 end --> 
            </div>
          </div>
        </div>
      </div>
    </div>
    <script>
    $(document).ready(function(e) {
        $(".modify").dblclick(function(){
            
            //alert(1);
              //$("p").text("haha");
              var txt = $(".modfy"+$(this).attr('key')).text(); 
              //value='" + txt + "'
                var input = "<input type='text' value='" + txt + "'/>"; 
              $(".modfy"+$(this).attr('key')).html(input);
          });
    });
    $(".update").click(function(e) {
        e.preventDefault();
        $("#myModal3 form").attr("action",$(this).attr("href"));
        $("#myModal3 .form-group").find('[name="changenum"]').val($(this).parents(".data_list").find("td:eq(4)").html());
        $("#myModal3 .form-group").find('[name="date"]').val($(this).parents(".data_list").find("td:eq(6)").html());
        $("#myModal3 .form-group  #editorr #ueditor_0").contents().find("body p").html($(this).parents(".data_list").find("td:eq(9)").html());  
        
        var str='';
        var id=$(this).attr("data-id");
        var typeid=$(this).attr("data-ruletype");
        var groupid=$(this).attr("data-groupid");
        var rewarderid=$(this).attr("data-rewarderid");
        
        
        //获取和设置积分规则
        $(".integralruletype").find("option[value='"+typeid+"']").attr("selected","selected");
        $.post("__GROUP__/Integral_rule/getrule",{'typeid':typeid},function(data){
            if(data.statu!=1){return;}
            console.log(typeid);
            $(".integralrule").html('<option value="">请选择积分事件</option>');
            $(data.integralrule).each(function(index, element) {
                str=element['id']==id?"selected='selected'":"";
                $(".integralrule").append("<option "+str+" value='"+element['id']+"'>"+element['name']+"</option>");
            });	
        },'json');
        
        //获取和设置奖惩人的部门
        $.getJSON("__GROUP__/Integral_rule/getmembergroup",{'id':rewarderid},function(data){
            if(data.statu!=1){return;}
            groupid=data.groupid
            $(".groupid").find("option[value='"+groupid+"']").attr("selected","selected");
            $.getJSON("__GROUP__/Integral_rule/getmember",{'groupid':groupid},function(data){
                if(data.statu!=1){return;}
                $(".memberid").html('<option value="">请选择职员</option>');
                $(data.member).each(function(index, element) {
                    str=element['id']==rewarderid?"selected='selected'":"";
                    $(".memberid").append('<option '+str+' value="'+element.id+'">'+element.name+'</option>');
                });
           });			
        });
        
        
        $("#myModal3").modal("show");
        
    });
    
    $(".f-changetype").click(function(e) {
        $("#myModal4 [name='id']").val($(this).attr("data-id"));
        $("#myModal4").modal("show");
    });
    </script> 
    <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script> 
    <include file="Public:footer" />
</if>